package com.atguigu.spzx.common.config;

import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

@Configuration
@Data
@ConfigurationProperties(prefix = "spzx.minio")
public class SpzxMinioConfig implements InitializingBean {
    private String endpoint;//: http://192.168.1.170:9001
    private String bucketName;//: spzx
    private String accessKey;//: admin
    private String secretKey;//: admin123456

    public static String ENDPOINT;
    public static String BUCKET_NAME;
    public static String ACCESS_KEY;
    public static String SECRET_KEY;

    //spring bean生命周期：  希望在容器给对象的属性值赋值后 执行一个方法 能够给静态属性赋值
    @Override
    public void afterPropertiesSet() throws Exception {
        //springbean提供的生命周期方法 在所有的properties属性值初始化后 调用
        ENDPOINT = this.endpoint;
        BUCKET_NAME = this.bucketName;
        ACCESS_KEY = this.accessKey;
        SECRET_KEY = this.secretKey;
    }
}
